package p270jp.pxv.android.viewholder;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.databinding.DataBindingUtil;
import p014ae.View$OnClickListenerC0151s;
import p060c2.Chain;
import p216hn.DefaultConstructorMarker;
import p270jp.pxv.android.R;
import p270jp.pxv.android.activity.NovelTextActivity;
import p270jp.pxv.android.legacy.model.PixivNovel;
import p270jp.pxv.android.model.PixivNovelSeriesDetail;
import p314lg.ViewHolderNovelSeriesDetailHeaderBinding;
import p325m0.MutabilityOwnership;
import p521th.FlexibleItemAdapterSolidItem;
import p521th.SolidItemViewHolder;
import p629xm._Collections;

/* compiled from: NovelSeriesDetailHeaderSolidItem.kt */
/* renamed from: jp.pxv.android.viewholder.NovelSeriesDetailHeaderSolidItem */
/* loaded from: classes2.dex */
public final class NovelSeriesDetailHeaderSolidItem extends FlexibleItemAdapterSolidItem {
    public static final int $stable;
    private final PixivNovelSeriesDetail novelSeriesDetail;
    private final PixivNovel novelSeriesLatestNovel;

    /* compiled from: NovelSeriesDetailHeaderSolidItem.kt */
    /* renamed from: jp.pxv.android.viewholder.NovelSeriesDetailHeaderSolidItem$NovelSeriesDetailHeaderViewHolder */
    /* loaded from: classes2.dex */
    public static final class NovelSeriesDetailHeaderViewHolder extends SolidItemViewHolder {
        public static final Companion Companion = new Companion(null);
        private static final int characterCountPerMinute;
        private final ViewHolderNovelSeriesDetailHeaderBinding binding;
        private final PixivNovelSeriesDetail novelSeriesDetail;
        private final PixivNovel novelSeriesLatestNovel;

        /* compiled from: NovelSeriesDetailHeaderSolidItem.kt */
        /* renamed from: jp.pxv.android.viewholder.NovelSeriesDetailHeaderSolidItem$NovelSeriesDetailHeaderViewHolder$Companion */
        /* loaded from: classes2.dex */
        public static final class Companion {
            private Companion() {
            }

            public /* synthetic */ Companion(DefaultConstructorMarker eVar) {
                this();
            }

            public final NovelSeriesDetailHeaderViewHolder createViewHolder(ViewGroup viewGroup, PixivNovelSeriesDetail pixivNovelSeriesDetail, PixivNovel pixivNovel) {
                MutabilityOwnership.m3745m(viewGroup, "parent");
                MutabilityOwnership.m3745m(pixivNovelSeriesDetail, "novelSeriesDetail");
                ViewHolderNovelSeriesDetailHeaderBinding w7Var = (ViewHolderNovelSeriesDetailHeaderBinding) DataBindingUtil.m11370c(LayoutInflater.from(viewGroup.getContext()), R.layout.view_holder_novel_series_detail_header, viewGroup, false);
                MutabilityOwnership.m3746l(w7Var, "binding");
                return new NovelSeriesDetailHeaderViewHolder(w7Var, pixivNovelSeriesDetail, pixivNovel, null);
            }
        }

        private NovelSeriesDetailHeaderViewHolder(ViewHolderNovelSeriesDetailHeaderBinding w7Var, PixivNovelSeriesDetail pixivNovelSeriesDetail, PixivNovel pixivNovel) {
            super(w7Var.f2666e);
            this.binding = w7Var;
            this.novelSeriesDetail = pixivNovelSeriesDetail;
            this.novelSeriesLatestNovel = pixivNovel;
        }

        public /* synthetic */ NovelSeriesDetailHeaderViewHolder(ViewHolderNovelSeriesDetailHeaderBinding w7Var, PixivNovelSeriesDetail pixivNovelSeriesDetail, PixivNovel pixivNovel, DefaultConstructorMarker eVar) {
            this(w7Var, pixivNovelSeriesDetail, pixivNovel);
        }

        /* renamed from: d */
        public static /* synthetic */ void m4411d(NovelSeriesDetailHeaderViewHolder novelSeriesDetailHeaderViewHolder, View view) {
            m12327onBindViewHolder$lambda1(novelSeriesDetailHeaderViewHolder, view);
        }

        /* renamed from: onBindViewHolder$lambda-0 */
        public static final void m12326onBindViewHolder$lambda0(NovelSeriesDetailHeaderViewHolder novelSeriesDetailHeaderViewHolder, View view) {
            MutabilityOwnership.m3745m(novelSeriesDetailHeaderViewHolder, "this$0");
            TextView textView = novelSeriesDetailHeaderViewHolder.binding.f22398q;
            textView.setMaxLines(textView.getLineCount());
            novelSeriesDetailHeaderViewHolder.binding.f22404w.setVisibility(8);
        }

        /* renamed from: onBindViewHolder$lambda-1 */
        public static final void m12327onBindViewHolder$lambda1(NovelSeriesDetailHeaderViewHolder novelSeriesDetailHeaderViewHolder, View view) {
            MutabilityOwnership.m3745m(novelSeriesDetailHeaderViewHolder, "this$0");
            Context context = view.getContext();
            NovelTextActivity.C4035a aVar = NovelTextActivity.f18449z0;
            Context context2 = view.getContext();
            MutabilityOwnership.m3746l(context2, "it.context");
            context.startActivity(aVar.m4779a(context2, novelSeriesDetailHeaderViewHolder.novelSeriesLatestNovel, null, null));
        }

        @Override // p521th.SolidItemViewHolder
        public void onBindViewHolder(int i) {
            String str;
            PixivNovelSeriesDetail pixivNovelSeriesDetail = this.novelSeriesDetail;
            if (pixivNovelSeriesDetail.isOriginal || pixivNovelSeriesDetail.isConcluded) {
                this.binding.f22401t.setVisibility(0);
                this.binding.f22402u.setVisibility(this.novelSeriesDetail.isOriginal ? 0 : 8);
                this.binding.f22400s.setVisibility(this.novelSeriesDetail.isConcluded ? 0 : 8);
            } else {
                this.binding.f22401t.setVisibility(8);
            }
            this.binding.f22397A.setText(this.novelSeriesDetail.title);
            int i2 = this.novelSeriesDetail.totalCharacterCount;
            int i3 = i2 / 30000;
            int i4 = (i2 % 30000) / 500;
            TextView textView = this.binding.f22407z;
            String[] strArr = new String[3];
            strArr[0] = textView.getContext().getString(R.string.novel_series_content_count, Integer.valueOf(this.novelSeriesDetail.contentCount));
            strArr[1] = this.binding.f22407z.getContext().getString(R.string.novel_characters_format, Integer.valueOf(this.novelSeriesDetail.totalCharacterCount));
            if (i3 == 0 && i4 == 0) {
                str = this.binding.f22407z.getContext().getString(R.string.novel_reading_time_1min_or_less);
            } else if (i3 == 0) {
                str = this.binding.f22407z.getContext().getString(R.string.novel_reading_time_n_min, Integer.valueOf(i4));
            } else if (i4 == 0) {
                str = this.binding.f22407z.getContext().getString(R.string.novel_reading_time_n_hrs, Integer.valueOf(i3));
            } else {
                str = this.binding.f22407z.getContext().getString(R.string.novel_reading_time_n_hrs_m_min, Integer.valueOf(i3), Integer.valueOf(i4));
            }
            strArr[2] = str;
            textView.setText(_Collections.m692V(Chain.m9925y(strArr), "\u2004\u2004", null, null, 0, null, null, 62));
            String str2 = this.novelSeriesDetail.caption;
            if (str2 == null || str2.length() == 0) {
                this.binding.f22399r.setVisibility(8);
            } else {
                this.binding.f22399r.setVisibility(0);
                this.binding.f22398q.setText(this.novelSeriesDetail.caption);
                this.binding.f22398q.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver$OnGlobalLayoutListenerC4398xd00f7313(this));
                Context context = this.binding.f22403v.getContext();
                TextView textView2 = this.binding.f22403v;
                textView2.setText(context.getString(R.string.novel_series_expand) + '\n' + context.getString(R.string.novel_series_expand));
                this.binding.f22404w.setOnClickListener(new View$OnClickListenerC4409j(this, 0));
            }
            if (this.novelSeriesLatestNovel == null) {
                this.binding.f22406y.setVisibility(8);
                return;
            }
            TextView textView3 = this.binding.f22405x;
            textView3.setText(textView3.getContext().getString(R.string.novel_series_read_last_work, Integer.valueOf(this.novelSeriesDetail.contentCount)));
            this.binding.f22406y.setVisibility(0);
            this.binding.f22406y.setOnClickListener(new View$OnClickListenerC0151s(this, 26));
        }
    }

    public NovelSeriesDetailHeaderSolidItem(PixivNovelSeriesDetail pixivNovelSeriesDetail, PixivNovel pixivNovel) {
        MutabilityOwnership.m3745m(pixivNovelSeriesDetail, "novelSeriesDetail");
        this.novelSeriesDetail = pixivNovelSeriesDetail;
        this.novelSeriesLatestNovel = pixivNovel;
    }

    @Override // p521th.FlexibleItemAdapterSolidItem
    public int getSpanSize() {
        return 1;
    }

    @Override // p521th.FlexibleItemAdapterSolidItem
    public SolidItemViewHolder onCreateViewHolder(ViewGroup viewGroup) {
        MutabilityOwnership.m3745m(viewGroup, "parent");
        return NovelSeriesDetailHeaderViewHolder.Companion.createViewHolder(viewGroup, this.novelSeriesDetail, this.novelSeriesLatestNovel);
    }

    @Override // p521th.FlexibleItemAdapterSolidItem
    public boolean shouldBeInserted(int i, int i2, int i3, int i4) {
        return i2 == 0;
    }
}
